﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Threading;

namespace PowerManager.Framework.DataPresentation.ProductData
{
    public sealed class ProductData : INotifyPropertyChanged
    {
        private IDictionary<String, String> Data;

        public ProductData() {
            Data = new Dictionary<String, String>();
        }

        public ProductData(IDictionary<String, String> data) {
            Data = data;
        }

        public String this[String index] {
            get { return Data[index]; }
            set {
                Data[index] = value;
                OnPropertyChanged(index);
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(String property) {
            var handle = Interlocked.CompareExchange(ref PropertyChanged, null, null);
            if (handle != null) {
                handle(this, new PropertyChangedEventArgs(property));
            }
        }
    }
}
